package chen.web.antispam;

import java.util.Map;

public class JudgeStore {

	private Map<String, Judge> mapping = new java.util.concurrent.ConcurrentHashMap<String, Judge>();
	
	public Judge createJudge(String action, RegulationGenerator generator){
		if(mapping.containsKey(action)){
			throw new RuntimeException("已经存在了一个相同动作的record:" + action);
		}
		Judge judge = new JudgeImpl(generator);
		mapping.put(action, judge);
		return judge;
	}
	
	public Judge createJudge(String action, final Regulation reg){
		RegulationGenerator generator = new RegulationGenerator(){
			@Override
			public Regulation generate() {
				// TODO Auto-generated method stub
				return reg;
			}
		};
		return createJudge(action, generator);
	}
	
	public Judge getJudge(String action){
		 Judge judge = mapping.get(action);
		 return judge;
	}
	
}
